package com.hxkj.controller;

import com.hxkj.domain.po.FunctionLibrary;
import com.hxkj.domain.po.FunctionLibraryTree;
import com.hxkj.service.FunctionLibraryService;
import com.platform.common.domain.result.ResultMessageStruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @ClassName FunctionLibraryController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/27 11:18
 * @Version 1.0
 */
@RestController
@RequestMapping(value = "/functionlibrary")
public class FunctionLibraryController {
    private static final Logger LOGGER = LoggerFactory.getLogger(FunctionLibraryController.class);

    @Autowired
    private FunctionLibraryService functionLibraryService;


    /**
    * @author Mr.zheng
    * @Description saveFunctionLibrary 新增功能
    * @Date 12:31 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
    **/
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Callable<ResultMessageStruct> saveFunctionLibrary(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.saveFunctionLibrary(functionLibrary);
    }


    /**
    * @author Mr.zheng
    * @Description modifyFunctionLibrary 修改功能
    * @Date 12:54 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
    **/
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public Callable<ResultMessageStruct> modifyFunctionLibrary(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.modifyFunctionLibrary(functionLibrary);
    }

    /**
    * @author Mr.zheng
    * @Description getFunctionLibraryListTree 获取功能树
    * @Date 12:54 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.hxkj.domain.po.FunctionLibraryTree>
    **/
    @RequestMapping(value = "/getlisttree", method = RequestMethod.POST)
    public Callable<List<FunctionLibraryTree>> getFunctionLibraryListTree(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.getFunctionLibraryListTree(functionLibrary);
    }

    /**
    * @author Mr.zheng
    * @Description getFunctionLibraryListTree 关键字搜索获取功能树
    * @Date 12:54 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.hxkj.domain.po.FunctionLibraryTree>
    **/
    @RequestMapping(value = "/getlisttreebykeyword", method = RequestMethod.POST)
    public Callable<List<FunctionLibraryTree>> getFunctionLibraryListTreeByKeyword(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.getFunctionLibraryListTreeByKeyword(functionLibrary);
    }


    /**
    * @author Mr.zheng
    * @Description getShowFunctionLibraryListTree 获取状态启用的功能树
    * @Date 12:54 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.hxkj.domain.po.FunctionLibraryTree>
    **/
    @RequestMapping(value = "/getshowlisttree", method = RequestMethod.POST)
    public Callable<List<FunctionLibraryTree>> getShowFunctionLibraryListTree(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.getShowFunctionLibraryListTree(functionLibrary);
    }


    /**
    * @author Mr.zheng
    * @Description removeFunctionLibrary 删除功能
    * @Date 13:08 2018/6/27
    * @Param [functionLibrary]
    * @return java.util.concurrent.Callable<com.platform.common.domain.result.ResultMessageStruct>
    **/
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public Callable<ResultMessageStruct> removeFunctionLibrary(@RequestBody FunctionLibrary functionLibrary) throws Exception{
        return () -> functionLibraryService.removeFunctionLibrary(functionLibrary);
    }

//    /**
//     * @author Mr.zheng
//     * @Description getFunctionLibraryListTree 根据ID获取功能
//     * @Date 12:54 2018/6/27
//     * @Param [functionLibrary]
//     * @return java.util.concurrent.Callable<com.hxkj.domain.po.FunctionLibraryTree>
//     **/
//    @RequestMapping(value = "/functiontosite", method = RequestMethod.POST)
//    public Callable<ResultMessageStruct> functionToSite(@RequestBody FunctionLibrary functionLibrary) throws Exception{
//        return () -> functionLibraryService.functionToSite(functionLibrary);
//    }
}
